//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "Array.h"
using namespace Cephei::QL::Math;
#undef HANDLE
#undef ABSTRACT
#define STRUCT
Cephei::QL::Math::CArray::CArray (Cephei::QL::Math::IArray^ prm1) 
{
	_pSpinlock = new boost::detail::spinlock ();
    CArray^ _Cprm1;
    try
    {
#ifdef HANDLE
        _phArray = NULL;
#endif
        _Cprm1 = safe_cast<CArray^> (prm1);
        _Cprm1->Lock();
        QuantLib::Array& _prm1 = static_cast<QuantLib::Array&> (_Cprm1->GetReference ()); 
        _ppArray = new boost::shared_ptr<QuantLib::Array> (new QuantLib::Array ( _prm1 ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cprm1 != nullptr) _Cprm1->Unlock();
    }
}
Cephei::QL::Math::CArray::CArray (UInt64 size, Double value, Double increment) 
{
	_pSpinlock = new boost::detail::spinlock ();
    try
    {
#ifdef HANDLE
        _phArray = NULL;
#endif
        QuantLib::Size _size = (QuantLib::Size)ValueHelper::Convert (size);
        QuantLib::Real _value = (QuantLib::Real)ValueHelper::Convert (value);
        QuantLib::Real _increment = (QuantLib::Real)ValueHelper::Convert (increment);
        _ppArray = new boost::shared_ptr<QuantLib::Array> (new QuantLib::Array ( _size,  _value,  _increment ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::CArray::CArray (UInt64 size, Double value) 
{
	_pSpinlock = new boost::detail::spinlock ();
    try
    {
#ifdef HANDLE
        _phArray = NULL;
#endif
        QuantLib::Size _size = (QuantLib::Size)ValueHelper::Convert (size);
        QuantLib::Real _value = (QuantLib::Real)ValueHelper::Convert (value);
        _ppArray = new boost::shared_ptr<QuantLib::Array> (new QuantLib::Array ( _size,  _value ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::CArray::CArray (Microsoft::FSharp::Core::FSharpOption<UInt64>^ size) 
{
	_pSpinlock = new boost::detail::spinlock ();
    try
    {
#ifdef HANDLE
        _phArray = NULL;
#endif
        QuantLib::Size _size = 
            (Microsoft::FSharp::Core::FSharpOption<UInt64>::IsSome::get (size) ? (QuantLib::Size)ValueHelper::Convert (size->Value) : 0); //4
        _ppArray = new boost::shared_ptr<QuantLib::Array> (new QuantLib::Array ( _size ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::CArray::CArray (boost::shared_ptr<QuantLib::Array>& childNative, Object^ owner) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phArray = NULL;
#endif
	_ppArray = &childNative;
    
}
Cephei::QL::Math::CArray::CArray (QuantLib::Array& childNative, Object^ owner) 
{
#ifdef HANDLE
	_phArray = NULL;
#endif
	_ppArray = new boost::shared_ptr<QuantLib::Array> (&childNative);
    
    _ArrayOwner = owner;
    
}

Cephei::QL::Math::CArray::CArray (CArray^ copy) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phArray = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppArray = new boost::shared_ptr<QuantLib::Array> (copy->GetShared());
        
    }
}
Cephei::QL::Math::CArray::CArray (System::Type^ t) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phArray = NULL;
#endif
	if (!t->IsSubclassOf(CArray::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::CArray::CArray (QuantLib::Handle<QuantLib::Array>& childNative, Object^ owner)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phArray = &childNative;
	_ppArray = &static_cast<boost::shared_ptr<QuantLib::Array>>(childNative.currentLink());
    
    _ArrayOwner = owner;
}
Cephei::QL::Math::CArray::CArray (QuantLib::Handle<QuantLib::Array> childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phArray = &childNative;
	_ppArray = &static_cast<boost::shared_ptr<QuantLib::Array>>(childNative.currentLink());
    
}
#endif
#ifdef STRUCT
Cephei::QL::Math::CArray::CArray (QuantLib::Array childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phArray = NULL;
#endif
	_ppArray = new boost::shared_ptr<QuantLib::Array> (new QuantLib::Array (childNative));
    
}
#endif

Cephei::QL::Math::CArray::~CArray ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
        _pSpinlock = NULL;
    }
    if (_ppArray != NULL)
    {
	    delete _ppArray;
        _ppArray = NULL;
    }
}
Cephei::QL::Math::CArray::!CArray ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
    }
    if (_ppArray != NULL)
    {
	    delete _ppArray;
    }
}
QuantLib::Array& Cephei::QL::Math::CArray::GetReference ()
{
    if (_ppArray == NULL) throw gcnew NativeNullException ();
	return **_ppArray;
}
boost::shared_ptr<QuantLib::Array>& Cephei::QL::Math::CArray::GetShared ()
{
    if (_ppArray == NULL) throw gcnew NativeNullException ();
	return *_ppArray;
}
QuantLib::Array* Cephei::QL::Math::CArray::GetPointer ()
{
    if (_ppArray == NULL) throw gcnew NativeNullException ();
	return &**_ppArray;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::Array>& Cephei::QL::Math::CArray::GetHandle ()
{
	if (_phArray == NULL)
	{
		_phArray = new Handle<QuantLib::Array> (*_ppArray);
	}
	return *_phArray;
}
#endif
bool Cephei::QL::Math::CArray::HasNative () 
{
	return (_ppArray != NULL);
}

Double Cephei::QL::Math::CArray::At (UInt64 prm1)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Size _prm1 = (QuantLib::Size)ValueHelper::Convert (prm1);
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppArray)->at ( _prm1 );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Math::CArray::Back::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppArray)->back ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Math::CArray::Begin::get ()
{
    try
    {
    	const QuantLib::Real* _rv = (const QuantLib::Real*)(*_ppArray)->begin ( );   
        Double _nrv = (Double)ValueHelper::Convert (*_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Boolean Cephei::QL::Math::CArray::Empty::get ()
{
    try
    {
    	bool _rv = (bool)(*_ppArray)->empty ( );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Math::CArray::End::get ()
{
    try
    {
    	const QuantLib::Real* _rv = (const QuantLib::Real*)(*_ppArray)->end ( );   
        Double _nrv = (Double)ValueHelper::Convert (*_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Math::CArray::Front::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppArray)->front ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
UInt64 Cephei::QL::Math::CArray::Size::get ()
{
    try
    {
    	QuantLib::Size _rv = (QuantLib::Size)(*_ppArray)->size ( );   
        UInt64 _nrv = (UInt64)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::IArray^ Cephei::QL::Math::CArray::Swap (Cephei::QL::Math::IArray^ prm1)
{
    CArray^ _Cprm1;
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        _Cprm1 = safe_cast<CArray^> (prm1);
        _Cprm1->Lock();
        QuantLib::Array& _prm1 = static_cast<QuantLib::Array&> (_Cprm1->GetReference ()); 
    	(*_ppArray)->swap ( _prm1 );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cprm1 != nullptr) _Cprm1->Unlock();
    }
}
Cephei::QL::Math::CArrayVector::CArrayVector ()
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
}
Cephei::QL::Math::CArrayVector::~CArrayVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
	_pVValue = NULL;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
	_pVBoost = NULL;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
	_pVHand = NULL;
#endif
}
Cephei::QL::Math::CArrayVector::!CArrayVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
#endif
}
#ifdef STRUCT
Cephei::QL::Math::CArrayVector::CArrayVector (std::vector<QuantLib::Array>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = &vec;
	_owner = owner;
}
Cephei::QL::Math::CArrayVector::CArrayVector (std::vector<QuantLib::Array> vec)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = new std::vector<QuantLib::Array> (vec);
}
#endif
Cephei::QL::Math::CArrayVector::CArrayVector (std::vector<boost::shared_ptr<QuantLib::Array>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVBoost = &vec;
	_owner = owner;
}
#ifdef HANDLE
Cephei::QL::Math::CArrayVector::CArrayVector (std::vector<QuantLib::Handle<QuantLib::Array>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVHand = &vec;
	_owner = owner;
}
#endif

int Cephei::QL::Math::CArrayVector::Count::get ()
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
		return _pVValue->size();
	}
#endif    
	if (_pVBoost != NULL)
	{
		return _pVBoost->size ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		return _pVHand->size ();
	}
#endif
	return 0;		// should never happen
}
Cephei::QL::Math::IArray^ Cephei::QL::Math::CArrayVector::default::get (int index) 
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
    	if ((size_t)index >= _pVValue->size()) throw gcnew RangeException ();
		QuantLib::Array& native = (*_pVValue)[index];
		return gcnew CArray (native, this);
	}
#endif    
	if (_pVBoost != NULL)
	{
    	if ((size_t)index >= _pVBoost->size()) throw gcnew RangeException ();
		QuantLib::Array& native = *(*_pVBoost)[index];
		return gcnew CArray (native, this);
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
    	if ((size_t)index >= _pVHand->size()) throw gcnew RangeException ();
		QuantLib::Array& native = *((*_pVHand)[index].currentLink ());
		return gcnew CArray (native, this);
	}
#endif
	return nullptr;		// can never be the case
}
void Cephei::QL::Math::CArrayVector::default::set (int index, Cephei::QL::Math::IArray^ value) 
{
#ifdef STRUCT
	if (_pVValue != NULL)
	{
		if (_pVValue->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVValue->size() < (size_t)index)
			{
				throw gcnew RangeException ();
			}
			_pVValue->push_back (dynamic_cast<CArray^>(value)->GetReference ());
		}
        else
        {
            QuantLib::Array& c = (*_pVValue)[index];
            c = dynamic_cast<CArray^>(value)->GetReference ();
        }
	}
#endif   
	if (_pVBoost != NULL)
	{
		if (_pVBoost->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVBoost->size() < (size_t)index)
			{
				throw gcnew RangeException ();
			}
			_pVBoost->push_back (dynamic_cast<CArray^>(value)->GetShared ());
		}
		boost::shared_ptr<QuantLib::Array>& c = (*_pVBoost)[index];
		c = dynamic_cast<CArray^>(value)->GetShared ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		if (_pVHand->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVHand->size() < (size_t)index)
			{
				throw gcnew RangeException ();
			}
			_pVHand->push_back (QuantLib::Handle<QuantLib::Array> ());
		}
		QuantLib::Handle<QuantLib::Array>& c = (*_pVHand)[index];
		boost::shared_ptr<QuantLib::Array>& b = static_cast<boost::shared_ptr<QuantLib::Array>>(c.currentLink());
		b = dynamic_cast<CArray^>(value)->GetShared ();
	}
#endif
}
Cephei::Generic::ICell<Cephei::QL::Math::IArray^>^ Cephei::QL::Math::CArrayVector::CItem::get (int index) 
{
	return CellBuilder::Instance->Create<IArray^> (dynamic_cast<IArray^>(default[index]));
}

void Cephei::QL::Math::CArrayVector::CItem::set (int index, Cephei::Generic::ICell<Cephei::QL::Math::IArray^>^ value) 
{
	default[index] = safe_cast<IArray^>(value->Value);
}
#ifdef STRUCT
std::vector<QuantLib::Array>& Cephei::QL::Math::CArrayVector::GetReference ()
{
	 return *_pVValue;
}
#endif

std::vector<boost::shared_ptr<QuantLib::Array>>& Cephei::QL::Math::CArrayVector::GetShared ()
{
	return *_pVBoost;
}

#ifdef HANDLE
std::vector<QuantLib::Handle<QuantLib::Array>>& Cephei::QL::Math::CArrayVector::GetHandle ()
{
	return *_pVHand;
}
#endif
bool Cephei::QL::Math::CArrayVector::PrepareFeature (NativeFeature feature)
{
	switch (feature)
	{
#ifdef STRUCT
		case NativeFeature::Value :
			if (_pVValue == NULL)
			{
				_pVValue = new std::vector<QuantLib::Array> ();
				return true;
			}
			break;
#endif
        case NativeFeature::shared_ptr :
			if (_pVBoost == NULL)
			{
				_pVBoost = new std::vector<boost::shared_ptr<QuantLib::Array>> ();
				return true;
			}
			break;
#ifdef HANDLE
        case NativeFeature::Handle :
            if (_pVHand == NULL)
            {
                _pVHand = new std::vector<QuantLib::Handle<QuantLib::Array>> ();
                return true;
            }
            break;
#endif
	}
	return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Math::IArray^ Cephei::QL::Math::CArray_Factory::Create (Cephei::QL::Math::IArray^ prm1)
{
    return gcnew CArray ( prm1);
}
Cephei::QL::Math::IArray^ Cephei::QL::Math::CArray_Factory::Create (UInt64 size, Double value, Double increment)
{
    return gcnew CArray ( size,  value,  increment);
}
Cephei::QL::Math::IArray^ Cephei::QL::Math::CArray_Factory::Create (UInt64 size, Double value)
{
    return gcnew CArray ( size,  value);
}
Cephei::QL::Math::IArray^ Cephei::QL::Math::CArray_Factory::Create (Microsoft::FSharp::Core::FSharpOption<UInt64>^ size)
{
    return gcnew CArray ( size);
}
/* <summary>Create a single dimension array of Array that can be passed into other function </summary> */
IVector<Cephei::QL::Math::IArray^>^ Cephei::QL::Math::CArray_Factory::CreateVector ()
 {
	 return gcnew CoVector<IArray^> (gcnew CArrayVector ());
 }
IVector<Cephei::QL::Math::IArray^>^ Cephei::QL::Math::CArray_Factory::CreateVector (System::Collections::Generic::IEnumerable<IArray^>^ source)
 {
	 return gcnew CoVector<IArray^> (source, gcnew CArrayVector ());
 }
/* <summary>Create a single dimension array of Array with change events</summary> */
Cephei::Generic::ICell<IVector<Cephei::Generic::ICell<Cephei::QL::Math::IArray^>^>^>^ Cephei::QL::Math::CArray_Factory::CreateCellVector ()
 {
	 return CellBuilder::Instance->Create<IVector<Cephei::Generic::ICell<Cephei::QL::Math::IArray^>^>^> (gcnew CoCellVector<Cephei::Generic::ICell<Cephei::QL::Math::IArray^>^> (gcnew CArrayVector ()));
 }
Cephei::Generic::ICell<IVector<Cephei::Generic::ICell<Cephei::QL::Math::IArray^>^>^>^ Cephei::QL::Math::CArray_Factory::CreateCellVector (System::Collections::Generic::IEnumerable<Cephei::Generic::ICell<Cephei::QL::Math::IArray^>^>^ source)
 {
	 return CellBuilder::Instance->Create<IVector<Cephei::Generic::ICell<Cephei::QL::Math::IArray^>^>^> (gcnew CoCellVector<Cephei::Generic::ICell<Cephei::QL::Math::IArray^>^> (source, gcnew CArrayVector ()));
 }

